package jobs.job3.classloaderdemo.server.loader;

import jobs.job3.classloaderdemo.server.standard.Task;

import java.io.DataOutputStream;
import java.io.OutputStream;

public class ExecutableTask {
    Task<?,?> task;
    byte[] input;


    public void execute(OutputStream out) throws Exception {
        System.out.println("开始执行《计算任务》---------任务日志如下---------");
        byte[] bytes = task.execute(input);
        System.out.println("《计算任务》执行完成----------------------------");
        DataOutputStream dos = new DataOutputStream(out);
        dos.writeInt(bytes.length);
        dos.write(bytes);
        out.flush();
    }

    public ExecutableTask(Task<?,?> task, byte[] input) {
        this.task = task;
        this.input = input;
    }
}
